package day03;

import java.util.Scanner;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/9
 */
public class Test07 {
    public static void main(String[] args) {
        // 产生一个1－100之间的随机整数
        int number = (int)(Math.random() * 100) + 1;
        Scanner sc = new Scanner(System.in);
        int guessCount = 0; // 猜测次数
        int MAX_GUESS = 7;  // 最大猜测次数

        System.out.println("猜数字的游戏");

        while (guessCount < MAX_GUESS) {
            System.out.print("请输入你猜测的数字（还剩" + (MAX_GUESS - guessCount) + "次机会）：");
            int guess = sc.nextInt();
            guessCount++;

            if (guess < number) {
                System.out.println("太小了，再大一点！");
            } else if (guess > number) {
                System.out.println("太大了，再小一点！");
            } else {
                System.out.println("恭喜你猜对了！");
                break;
            }
        }

        // 7次还未猜对
        System.out.println("你太笨了，下次再来吧！");
    }
}
